package com.zxw.mvpproject.ui.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.zxw.mvpproject.R;
import com.zxw.mvpproject.mvp.bean.Book;
import com.zxw.mvpproject.mvp.presenter.BookPresenter;
import com.zxw.mvpproject.mvp.view.BookView;

public class MainActivity extends AppCompatActivity implements BookView{

    private BookPresenter presenter;
    private TextView tv_book;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv_book = (TextView)findViewById(R.id.tv_book);
        presenter = new BookPresenter(this);
        presenter.onCreate();
        presenter.attachView(this);
        presenter.getSearchBook("金瓶梅",null,0,1);

    }

    @Override
    public void success(Book book) {
        tv_book.setText(book+"");
    }

    @Override
    public void fail(String errinfo) {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.onStop();
    }
}
